home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _A63B6F0F869D49698BC322020C41FF12 < prev    next >
Encoding:
Text File  |  2004-01-06  |  1.6 KB  |  63 lines

  1. // ===============================================================
  2. // Vertex Program: Low/Med spec water for NV1X class cards...
  3. // Description: used in for really low spec water volumes
  4. // Last Update: 29/11/2003
  5. // Coder: Tiago Sousa
  6. // ===============================================================
  7.  
  8. #include "../CGVPMacro.csi"
  9.  
  10. VertAttributes { POSITION_3 PRIM_COLOR }
  11.  
  12. // setup vertex components
  13. MainInput
  14. {
  15.   // common model view matrix
  16.   VIEWPROJ_MATRIX,
  17.   uniform float4   CameraPos,    
  18.   uniform float4   TexGenRipple0,
  19.   uniform float4   TexGenRipple1,
  20.   uniform float4   TexShiftRipple,
  21.   uniform float4   TexDetailScale,
  22.   uniform float4   WaterColor
  23. }
  24.  
  25. DeclarationsScript
  26. {
  27.   // vertex input
  28.   IN_C0
  29.   // vertex output
  30.   OUT_T0_T1_C0
  31. }
  32.  
  33. // output vertex position
  34. PositionScript = PosCommon
  35.  
  36. CoreScript
  37. {
  38.   float4 vHPos = mul(ModelViewProj, vPos);                
  39.   float3 eyeVec = normalize(CameraPos.xyz - vPos.xyz);  
  40.  
  41.   float3 fNormal=float3(0,0,1);
  42.   float fDot= dot(eyeVec, fNormal);  
  43.   
  44.   // output color and fresnel term hack           
  45.   OUT.Color.xyz=WaterColor.xyz;   
  46.   OUT.Color.w =max(0, IN.Color.w-(1/(vHPos.w*vHPos.w)));     
  47.           
  48.   float2 vTex;
  49.   vTex.x = dot(vPos, TexGenRipple0);
  50.   vTex.y = dot(vPos, TexGenRipple1);   
  51.   
  52.   float3 vNPos=normalize(vPos.xyz);
  53.   vTex.xy= (vTex.xy+TexShiftRipple.zw*TexShiftRipple.xy);
  54.  
  55.   // output texture coordinates  
  56.   OUT.Tex0.xy = vTex.xy;      
  57.     
  58.   float3 fReflVec=normalize(2*fDot*fNormal-eyeVec);     
  59.   OUT.Tex1.xy = ((fReflVec.xy+1.0)*0.5-TexShiftRipple.zw*TexShiftRipple.xy*0.2)*0.4; 
  60.        
  61.   return OUT;
  62. }
  63.